package com.bicon.botu.mall.component.dto;

import org.apache.commons.lang3.EnumUtils;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 地区字典code枚举类
 *
 * @author tandk
 * @date 2017/6/13 0013 下午 3:18
 */
public enum AreaDictionaryCodeEnum {

    /**
     *
     */
    COUNTRY("国家", 1),
    /**
     *
     */
    PROVINCE("省", 2),
    /**
     *
     */
    CITY("市", 3),
    /**
     *
     */
    REGION("区", 4);


    private String name;

    private int level;


    AreaDictionaryCodeEnum(String name, int level) {
        this.name = name;
        this.level = level;
    }
    public String getName() {
        return name;
    }

    public int getLevel() {
        return level;
    }

    public static List<AreaDictionaryCodeEnum> ALL = EnumUtils.getEnumList(AreaDictionaryCodeEnum.class);

    public static Map<String, Object> getKeyValueMap() {
        Map<String, Object> map = new LinkedHashMap();
        for (AreaDictionaryCodeEnum a : AreaDictionaryCodeEnum.ALL) {
            map.put(a.toString(), a.getLevel());
        }
        return map;
    }

    public static boolean isContains(String name) {
        for (AreaDictionaryCodeEnum a : ALL) {
            if (a.toString().equals(name))
                return true;
        }
        return false;
    }
}
